Adapt Your Add-Ons to CS-Cart 4.2.1

Familiarize yourself with the list of changes that can affect your add-ons operation when updating from 4.1.5 to 4.2.1 version.

They are not so numerous, but some of them affected CS-Cart functionality rather heavily.

Here is the list of main changes


Responsive Theme

New Responsive theme was added. You should check your add-ons design with the new theme and adapt it if needed.


SEO

Because of the fact that the SEO add-on was highly modified (see the list of changes in our blog), PHP functions were changed too. If your add-on works with the SEO functionality, check it.

As for hooks, here is the list of added, removed, and modified hooks:

Removed:

  • seo_static_cache
  • seo_empty_object_name

Changed:

  • get_seo_vars
  • get_rewrite_rules
  • seo_is_indexed_page
  • seo_url

For more information open: https://www.cs-cart.com/index.php?dispatch=hooks_base.manage&ver=4.2.1RC#238973

Choose “Compare with”: “CS-Cart Lifetime License” “4.1.5” and click Search.


Languages

PO files format was changed.

Old:

#. Editing product
msgctxt "Languages"
msgid "editing_product"
msgstr "Редактирование товара”

New:

msgctxt "Languages:tools_addons_restore_defaults"
msgid "Restore defaults"
msgstr "Восстановить стандартные настройки”

According to this, all PO files related functions were changed too.


Settings

The following settings:

  • Enable secure connection at checkout
  • Enable secure connection in the administration panel
  • Enable secure connection for authentication, profile and orders pages
  • Keep HTTPS connection once a secure page is visited

were moved from the General section of the administration panel to Security.

settings.General.secure_checkout -> settings.Security.secure_checkout
settings.General.keep_http -> settings.Security.keep_https
settings.General.secure_admin -> settings.Security.secure_admin
settings.General.secure_auth -> settings.Security.secure_auth
- Registry::get('settings.General.secure_checkout');
+ Registry::get('settings.Security.secure_checkout');

Example:

$secure_admin_value = Registry::get('settings.Security.secure_admin');

Also the following settings changed their names:

save_selected_layout -> save_selected_view
default_products_layout -> default_products_view
default_products_layout_templates -> default_products_view_templates
default_product_details_layout -> default_product_details_view
- Registry::get('settings.Appearance.save_selected_layout');
+ Registry::get('settings.Appearance.save_selected_view');

HTML5

We have completely switched to HTML5. There is no more need in the following structure in JavaScript code:

//<![CDATA[
...
//]]>

$config[‘resources’]

All the config variables with the resources paths were moved to $config['resources'].

$config['resources'] = array(
'knowledge_base' => 'http://kb.cs-cart.com/installation',
'updates_server' => 'http://updates.cs-cart.com',
'twitter' => 'cscart',
'feedback_api' => 'https://www.cs-cart.com/index.php?dispatch=feedback',
'product_url' => 'https://www.cs-cart.com',
'helpdesk_url' => 'https://www.cs-cart.com/helpdesk',
'license_url' => 'https://www.cs-cart.com/licenses.html',
'marketplace_url' => 'http://marketplace.cs-cart.com',
'admin_protection_url' => 'http://kb.cs-cart.com/adminarea-protection',
//'demo_store_url' => 'http://demo.cs-cart.com/' . strtolower(PRODUCT_EDITION) . '/'
);

$config['updates_server'] = 'http://updates.cs-cart.com'; //was left for now for the backward compatibility, but will be removed soon.
bad: Registry::get('config.updates_server’)
good: Registry::get('config.resources.updates_server')

Export/Import

  • The ability to import Order items for a non-existing order was removed.
  • The ability to import language variables for a non-existing language was removed.

Layouts: Blocks

The disable_cache flag for fillings was returned. Now it is possible to disable cache for certain fillings values (when creating the Random products block, for example).

'products' => array (
'content' => array (
'items' => array (
...

'fillings' => array (
'random_products' => array (
'params' => array (
'sort_by' => 'popularity',
'sort_order' => 'desc',
),
'disable_cache' => true,
),
),

...
),
),
),

Smarty

Smarty was updated to the latest version (3.1.15 -> 3.1.18).


fn_get_storefront_urls

The new helpful function was added:

+ /**
+  * Gets company storefront URLs
+  * @param integer $company_id company ID
+  * @param array $company_data company data (if passed, company_id won't be used)
+  * @return array storefront URLs
+  */
+ function fn_get_storefront_urls($company_id, $company_data = array())

301 Redirects

The is_permanent flag was added to the fn_redirect function. Now it is possible to create 301 redirects.

- function fn_redirect($location, $allow_external_redirect = false)
+ function fn_redirect($location, $allow_external_redirect = false, $is_permanent = false)

PRODUCT_NAME Constant

The PRODUCT_NAME constant was added.


Suppliers

The ability to create a common shipping method for all suppliers was added. The corresponding code was changed.


Extending Add-ons

If it is necessary to extend one add-on with another, now it is possible to select all hook functionality inside the add-on. For example, news_and_emails uses seo. Not to spread the seo functionality across all the news_and_emails functionality, it can be passed to a hook:

design/backend/templates/addons/news_and_emails/addons/seo/hooks/

The principles of working are the same as for the other hooks. One exception is that hooks from the addons catalog inside the news_and_emails add-on will be included only when the appropriate add-on is enabled (the SEO add-on in this example).

The 3rd parameter was added for registering the php hooks:

fn_register_hooks( array('get_news_data', '', 'seo') )

The name of a function processing a hook is fn_seo_get_news_data. It is called out when the SEO add-on is enabled.

Note

All the described actions take place in the News and emails add-on.


Banners

Now demo banners are always installed.


New Web Configuration File

The web configuration file for ISS servers was added (for htaccess). Check the var/conf/ directory.


The Instance Method

The instance method of the Settings class now allows to get settings of the defined company:

- public static function instance()
+ public static function instance($company_id = null)

HTACCESS Changes

htaccess now allows to download the .yml and .xml files from the var/ directory.


Hooks

- fn_set_hook('update_shipping_post', $shipping_data, $shipping_id, $lang_code);
+fn_set_hook('update_shipping_post', $shipping_data, $shipping_id, $lang_code, $action);

addon.xml

We have added a new version of the addon.xml file:

<addon scheme="3.0">

So, all the add-ons which have XML v3, support PO-files with translations.